package cn.darkhorse.ticket.basis.service.impl;

import cn.darkhorse.ticket.basis.mapper.TicketProductTypeMapper;
import cn.darkhorse.ticket.basis.pojo.TicketProduct;
import cn.darkhorse.ticket.basis.pojo.TicketProductType;
import cn.darkhorse.ticket.basis.service.TicketProductService;
import cn.darkhorse.ticket.basis.service.TicketProductTypeService;
import cn.darkhorse.ticket.code.RepeatCheck;
import cn.darkhorse.ticket.constants.TicketConstants;
import cn.darkhorse.ticket.service.IRepeatCheckService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 产品分类 服务实现类
 * </p>
 *
 * @author wangxinghui
 * @since 2024-01-09
 */
@Service
public class TicketProductTypeServiceImpl extends ServiceImpl<TicketProductTypeMapper, TicketProductType> implements TicketProductTypeService {

	@Resource
	private IRepeatCheckService<TicketProductType> repeatCheckService;
	@Resource
	private TicketProductService productService;
	@Resource
	RepeatCheck<TicketProductType> repeatCheck;
	
	@Override
	public String repeat(TicketProductType productType) {
		/*String code = null;
		if(null==productType.getId()){
			 code = repeatCheckService.repeatAutoCodeAndName(this, productType.getId(), TicketConstants.BUSINESS_TYPE_CPFL,
					productType.getCode(), productType.getName(), productType.getIsAutomatically());
		}else {
			repeatCheckService.repeatName(this,productType.getId(),productType.getName());
		}
		return code;*/
		return repeatCheck.repeat(this,productType,TicketConstants.BUSINESS_TYPE_CPFL);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@Override
	public boolean isQuote(Long id) {
		LambdaQueryWrapper<TicketProduct> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(TicketProduct::getProductTypeId,id);
		long count = productService.count(queryWrapper);
		return count>0?false:true;
	}
	
	
	
}
